-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support saving chat history in gr.ChatInterface
#10191
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/f136fece1af912a4802e3acbf82c84b9eb554ff8/gradio-5.9.1-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@f136fece1af912a4802e3acbf82c84b9eb554ff8#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/f136fece1af912a4802e3acbf82c84b9eb554ff8/gradio-client-1.8.0.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/f136fece1af912a4802e3acbf82c84b9eb554ff8/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@abidlabs I'll replace |
Yes exactly. We also need to actually save the chat history to the browser state, that functionality is currently not implemented |
You may find this PR useful: #10245 (or maybe not, not sure) |
* Declare exports * add changeset * type fixes * more type fixes * add changeset * notebooks * changes --------- Co-authored-by: gradio-pr-bot <[email protected]> Co-authored-by: Freddy Boulton <[email protected]> Co-authored-by: Abubakar Abid <[email protected]>
* changes * changes * add changeset * format * changes --------- Co-authored-by: gradio-pr-bot <[email protected]>
@abidlabs Did a first pass, and the functionality for chat conversation history should work, if you can test. Will push some changes to tweak the UI. |
Will take a look soon! |
Nice @dawoodkhan82! Core functionality to save to browser state is working for me and I like that the first message automatically becomes the title of the saved first chat. Some issues I noticed: (1) Clicking on the trash button in Chatbot causes the history to error out. And in a permanent way: if you refresh the page, you'll see that none of the chats in the history remain and you actually need to restart the Gradio server to get the chat history working again: Screen.Recording.2024-12-26.at.11.26.28.PM.mov(2) Uploading an image breaks the chat history feature as well: Screen.Recording.2024-12-26.at.11.27.45.PM.mov(3) When you load the chat from the history, its not synchronized with the chat state, so that if you send a subsequent message, it wipes out the chat history instead of "resuming" from the last message: Screen.Recording.2024-12-26.at.11.29.40.PM.mov(4) Also, the final chat that is stored to history seems to be used as the value for all of the chats. So if you click through the chats, all of them will have the same value actually: Screen.Recording.2024-12-26.at.11.31.17.PM.mov |
02caf94
to
bcd383e
Compare
Fixed isseus (3) and (4), working on the others |
There are some edge cases I need to fix (e.g. handling images and other non-text messages) but let me open for feedback, especially on the design side |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and lgtm!
Small nit: The plus icon in chat history is black in dark mode. I tried fixing it but it seems like we have to change the styling in the Button component, which might cause other issues
stroke="currentColor" might fix, e.g. https://github.com/gradio-app/gradio/blob/main/js/icons/src/Erase.svelte#L11 |
@aliabid94 gradio/js/button/shared/Button.svelte Line 53 in 2b23e7f
|
Ah good catch, I wonder if we can change it to gray or something |
Pushed up some changes (just docs/guides) |
657e085
to
01363e2
Compare
Thanks folks! I have updated the icon to a shape and color that looks good in dark and light mode: Will merge this in once CI runs. Thanks @dawoodkhan82 @aliabid94 @hannahblair! |
Test with:
demo/chatinterface_save_history/run.py
Closes: #10045